package cn.samler.shopapi.Service.impl;

import cn.samler.shopapi.Entity.Address;
import cn.samler.shopapi.Entity.User;
import cn.samler.shopapi.Mapper.AddressMapper;
import cn.samler.shopapi.Service.AddressService;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class AddressServiceImpl implements AddressService {
    private final AddressMapper addressMapper;

    AddressServiceImpl(AddressMapper addressMapper) {
        this.addressMapper = addressMapper;
    }

    @Override
    public List<Address> getAddressAll(User user) {
        return addressMapper.getAddressAll(user.getId());
    }

    @Override
    public Address getAddressById(User user, int id) {
        return addressMapper.getAddressById(user.getId(), id);
    }

    @Override
    public boolean updateAddress(User user, Address address) {
        return addressMapper.updateAddress(user.getId(), address);
    }

    @Override
    public boolean insertAddress(User user, Address address) {
        return addressMapper.insertAddress(user.getId(), address);
    }

    @Override
    public boolean deleteAddress(User user, int id) {
        return addressMapper.deleteAddress(user.getId(), id);
    }

    @Override
    public boolean setDefaultAddress(User user, int id) {
        return addressMapper.setDefaultAddress(user.getId(), id);
    }

}
